Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
Need to get each "link" entry from nested json using js

There is a json code. Consisting by type: {"123":{...},"321":{...}} In it, you need to get "links" from each entry. I couldn't understand this note, please help me.

{
"3782474584475521065": {
    "listingid": "3782474584475521065",
    "price": 16,
    "asset": {
        "currency": 0,
        "appid": 730,
        "contextid": "2",
        "id": "25996697315",
        "amount": "1",
        "market_actions": [
            {
                "link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D2354938592644984102",
                "name": "Осмотреть в игре…"
            }
        ]
    }
},
"3782474584475520325": {
    "listingid": "3782474584475520325",
    "price": 16,
    "asset": {
        "currency": 0,
        "appid": 730,
        "contextid": "2",
        "id": "25996698023",
        "amount": "1",
        "market_actions": [
            {
                "link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D9866835690490179400",
                "name": "Осмотреть в игре…"
            }
        ]
    }
}

}

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If I understood your question correctly, you need to extract the links from the json text. This is a solution:

const a = {
  "3782474584475521065": {
    listingid: "3782474584475521065",
    price: 16,
    asset: {
      currency: 0,
      appid: 730,
      contextid: "2",
      id: "25996697315",
      amount: "1",
      market_actions: [
        {
          link: "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D2354938592644984102",
          name: "Осмотреть в игре…",
        },
      ],
    },
  },
  "3782474584475520325": {
    listingid: "3782474584475520325",
    price: 16,
    asset: {
      currency: 0,
      appid: 730,
      contextid: "2",
      id: "25996698023",
      amount: "1",
      market_actions: [
        {
          link: "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D9866835690490179400",
          name: "Осмотреть в игре…",
        },
      ],
    },
  },
};

// get links from a
const links = Object.values(a).map(({ asset }) => {
  const { market_actions } = asset;
  const { link } = market_actions[0];
  return link;
});

console.log(links);

This simply iterates through the object's values and accesses the link values through object extraction.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Return an array of objects {id:link}

const data = {
  "3782474584475521065": {
    "listingid": "3782474584475521065",
    "price": 16,
    "asset": {
      "currency": 0,
      "appid": 730,
      "contextid": "2",
      "id": "25996697315",
      "amount": "1",
      "market_actions": [
          {
              "link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D2354938592644984102",
              "name": "Осмотреть в игре…"
          }
      ]
    }
  },
  "3782474584475520325": {
    "listingid": "3782474584475520325",
    "price": 16,
    "asset": {
      "currency": 0,
      "appid": 730,
      "contextid": "2",
      "id": "25996698023",
      "amount": "1",
      "market_actions": [
          {
              "link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D9866835690490179400",
              "name": "Осмотреть в игре…"
          }
      ]
    }
  }
}
const result = Object.entries(data).map(([key, {asset, ...rest}]) => ({[key]: asset.market_actions[0].link}))
console.log(result)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda